//
//  MainTabBarController.swift
//  Sina Weibo
//
//  Created by 斩尘 on 15/10/2.
//  Copyright © 2015年 陈帅. All rights reserved.
//

import UIKit

class MainTabBarController: UITabBarController {


    @IBOutlet weak var mainTabBar: MainTabBar!
    override func viewDidLoad() {
        super.viewDidLoad()


        addChildViewControllers()
       
        mainTabBar.composeButton.addTarget(self, action: "composeDidClick", forControlEvents: UIControlEvents.TouchUpInside)
        
    
    }
    
    func composeDidClick() {
    
        print("哈哈")
    }

    
    func addChildViewControllers(){
    self.tabBar.tintColor = UIColor.orangeColor()

      addchildViewController("Home", title: "首页", imageName: "tabbar_home")
              addchildViewController("Message", title: "消息", imageName: "tabbar_message_center")
              addchildViewController("Discover", title: "发现", imageName: "tabbar_discover")
              addchildViewController("Profile", title: "我", imageName: "tabbar_profile")
        
    }
    
    func addchildViewController(sbName : String,title: String, imageName: String) {
    
        let sb = UIStoryboard(name: sbName, bundle: nil)
        
        let nav = sb.instantiateInitialViewController() as! UINavigationController
        
//        设置title
        nav.topViewController?.title = title
//        nav.title = title
        
        
        nav.tabBarItem.image = UIImage(named: imageName)
        
        addChildViewController(nav)
        
    }
    
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }
    


}
